package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.AWzs;
import com.ruoyi.system.service.IAWzsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 要素链的完整性Controller
 *
 * @author ruoyi
 * @date 2020-07-08
 */
@Controller
@RequestMapping("/system/glx")
public class AGlxController extends BaseController {
    private String prefix = "system/glx";

    @Autowired
    private IAWzsService aWzsService;

    @GetMapping()
    public String wzs() {
        return prefix + "/glx";
    }

    /**
     * 查询要素链的完整性列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AWzs aWzs) {
        startPage();
        List<AWzs> list = aWzsService.selectAWzsList(aWzs);
        return getDataTable(list);
    }

    /**
     * 导出要素链的完整性列表
     */
    @Log(title = "要素链的完整性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AWzs aWzs) {
        List<AWzs> list = aWzsService.selectAWzsList(aWzs);
        ExcelUtil<AWzs> util = new ExcelUtil<AWzs>(AWzs.class);
        return util.exportExcel(list, "glx");
    }

    /**
     * 新增要素链的完整性
     */
    @GetMapping("/add")
    public String add(String c_type, ModelMap mmap) {
        mmap.put("c_type", c_type);
        return prefix + "/add";
    }

    /**
     * 新增保存要素链的完整性
     */
    @Log(title = "要素链的完整性", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AWzs aWzs) {
        return toAjax(aWzsService.insertAWzs(aWzs));
    }

    /**
     * 修改要素链的完整性
     */
    @GetMapping("/edit/{aCid}")
    public String edit(@PathVariable("aCid") Long aCid, ModelMap mmap) {
        AWzs aWzs = aWzsService.selectAWzsById(aCid);
        mmap.put("aWzs", aWzs);
        return prefix + "/edit";
    }

    /**
     * 修改保存要素链的完整性
     */
    @Log(title = "要素链的完整性", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AWzs aWzs) {
        return toAjax(aWzsService.updateAWzs(aWzs));
    }

    /**
     * 删除要素链的完整性
     */
    @Log(title = "要素链的完整性", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(aWzsService.deleteAWzsByIds(ids));
    }



}
